package com.impl.webConfig;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

@Configuration
@EnableSwagger2
public class SwaggerConfig {


    /**
     * 实现Docket实例
     *
     * @return
     */
    @Bean
    public Docket webApiConfigDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("adminApiConfig")
                .apiInfo(apiInfo())
                .select()
//                .paths(PathSelectors.any())
                .paths(PathSelectors.regex("/admin/.*"))
                .build();
    }

    @Bean
    public Docket adminApiConfigDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("webApiConfig")
                .apiInfo(apiInfo())
                .select()
                .paths(PathSelectors.regex("/api/.*"))
                .build();
    }


    public static final Contact DEFAULT_CONTACT = new Contact("LiMM", "www.baidu.com", "kuye910@163.com");

    private ApiInfo apiInfo() {

        return new ApiInfo("这个关于【Spring Boot--Mybatis-Plus--Redis】Application",
                "x血虽未冷、心却已寒",
                "1.0",
                "urn:tos",
                DEFAULT_CONTACT,
                "Apache 2.0",
                "http://www.biliili.com",
                new ArrayList());
    }
}
